package com.kehutong.charge.service.impl;

import com.kehutong.charge.entity.*;
import com.kehutong.charge.service.CommonService;
import com.kehutong.charge.service.ThirdPayManageService;
import com.kehutong.charge.util.CommonUtil;
import com.kehutong.charge.util.enums.*;
import com.kehutong.charge.vo.ChargeReFundApplyExcelVO;
import com.kehutong.charge.vo.ChargeReFundManageExcelVO;
import com.kehutong.charge.service.ChargeReFundService;
import com.kehutong.charge.util.CommonClient;
import com.kehutong.common.DoveClient;
import com.kehutong.common.errcode.Assert;
import com.kehutong.common.errcode.Result;
import com.kehutong.common.excel.tool.ExcelTool;
import com.kehutong.common.util.BigDecimalUtils;
import com.kehutong.common.util.ListUtils;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONArray;
import org.coraframework.json.JSONObject;
import org.coraframework.logger.Logger;
import org.coraframework.logger.LoggerFactory;
import org.coraframework.orm.Pool;
import org.coraframework.orm.jdbc.JdbcSession;
import org.coraframework.orm.jdbc.Page;
import org.coraframework.orm.jdbc.execute.entity.FindPage;
import org.coraframework.util.IDGenerate;
import org.coraframework.util.Objects;
import org.coraframework.util.time.TimeUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: kht
 * @description: ChargeReFundServiceImpl
 * @author: joneron
 * @create: 2021/7/5
 **/
public class ChargeReFundServiceImpl implements ChargeReFundService {

    private static final Logger logger = LoggerFactory.getLogger(ThirdPayManageServiceImpl.class);

    @Inject
    private JdbcSession jdbcSession;
    @Inject
    private CommonClient commonClient;
    @Inject
    private ExcelTool excelTool;
    @Inject
    ThirdPayManageService thirdPayManageService;
    @Inject
    private CommonService commonService;

    @Override
    public Page<ChargeReFundManage> findPage(JSONObject jsonObject) {
        FindPage<ChargeReFundManage> find = jdbcSession.findPage(ChargeReFundManage.class)
                .eq("deleted", false)
                .eq(jsonObject,"communityNo")
                .eq(jsonObject,"houseBillNo")
                .eq(jsonObject,"applyStatus")
                .like(jsonObject,"createTime");

        String serviceNo = jsonObject.getString("serviceNo");
        if(Objects.nonEmpty(serviceNo)){
            find.markBegin();
            find.like("serviceNo",serviceNo).or();
            find.like("orderNo",serviceNo).or();
            find.markEnd();
        }

        //添加选中导出条件
        JSONArray exportIdList = jsonObject.getJSONArray("exportIdList");
        if(!Objects.isEmpty(exportIdList)){
            find.in("serviceNo",exportIdList);
        }
        find.order("createTime", "desc");

        find.page(jsonObject);

        return find.exe();
    }


    @Override
    public void pageManageExport(HttpServletRequest req, HttpServletResponse resp, JSONObject jsonObject) {
        jsonObject.put("pageNo", 1);
        jsonObject.put("pageSize", ExcelTool.MAX_ROWS);
        List<ChargeReFundManage> list = findPage(jsonObject).getList();
        Assert.notEmpty(list,"导出失败！没有找到相关的退款订单数据");
        List<ChargeReFundManageExcelVO> dtoList = ListUtils.copyList(list, ChargeReFundManageExcelVO::new);
        excelTool.excelDownload(req,resp,dtoList,"退款订单列表导出");
    }


    @Override
    public void pageApplyExport(HttpServletRequest req, HttpServletResponse resp, JSONObject jsonObject) {
        jsonObject.put("pageNo", 1);
        jsonObject.put("pageSize", ExcelTool.MAX_ROWS);
        List<ChargeReFundManage> list = findPage(jsonObject).getList();
        Assert.notEmpty(list,"导出失败！没有找到相关的退款申请数据");
        List<ChargeReFundApplyExcelVO> dtoList = ListUtils.copyList(list, ChargeReFundApplyExcelVO::new);
        excelTool.excelDownload(req,resp,dtoList,"退款申请列表导出");
    }

    @Override
    public Object getObj(JSONObject jsonObject) {
        return jdbcSession.findOne(ChargeReFundManage.class)
                .eq(jsonObject,"orderNo")
                .eq(jsonObject,"serviceNo")
                .eq(jsonObject,"userNo").exe();
    }




    @Override
    public List<ChargeReFundManage> findList(JSONObject jsonObject) {
        // 先屏蔽类目账单的退款信息
        String itemBillNo = jsonObject.getString("itemBillNo");
        if (!Objects.isBlank(itemBillNo)) {
            return new ArrayList<>();
        }

        return jdbcSession.findArray(ChargeReFundManage.class)
                .eq("deleted", false)
                .eq(jsonObject,"orderNo")
                .eq(jsonObject,"houseBillNo")
                .eq(jsonObject,"orderYearMonth")
                .eq(jsonObject,"userNo")
                .eq(jsonObject,"applyStatus")
                .eq(jsonObject,"houseNo")
                //.like("createTime", jsonObject.getString("billYearMonth"))
                .exe();
    }

    @Override
    public Object save(ChargeReFundManage chargeReFundManage) throws Exception {
        List<ChargeReFundManage> chargeReFundManageList = jdbcSession.findArray(ChargeReFundManage.class)
                .eq("deleted",false)
                .eq("applyStatus",ChargeStatusEnum.CS_UN_TREATED)
                .eq("orderNo",chargeReFundManage.getOrderNo()).exe();
        if(chargeReFundManageList.size()>0){
            logger.error("退款订单：{}，退款正在处理中！",chargeReFundManage.getOrderNo());
            return Result.error(1231,"退款正在处理中！");
        }

        chargeReFundManage.setServiceNo(CommonUtil.generateRandom("TK"));

        // 订单临时入口和常规入口
        if(CommonEnum.COM_PAY_ROUTINE.getId().equals(chargeReFundManage.getOrderOrigin())){
            return routineAmount(chargeReFundManage);
        }else if (CommonEnum.COM_PAY_INTERIM.getId().equals(chargeReFundManage.getOrderOrigin())){
            return interimAmount(chargeReFundManage);
        }

        return Result.success();
    }

    /**
     * 临时入口
     * @param chargeReFundManage
     * @return
     */
    private Object interimAmount(ChargeReFundManage chargeReFundManage) throws Exception {

        //请求订单
        ChargeOrderInterim orderInterim = jdbcSession.findOne(ChargeOrderInterim.class)
                .eq("interimOrderNo",chargeReFundManage.getOrderNo()).exe();

        //1、查詢是否有配置数据
        ChargeRefundConfig config= jdbcSession.findOne(ChargeRefundConfig.class)
                .eq("deleted", false)
                .eq("communityNo",orderInterim.getCommunityNo())
                .eq("status",true).exe();

        if(null != config ){
            //需要审核
            if(config.getApproveMethod().getId().equals(EnableStateEnum.UNUSED.getId())){
                chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_UN_TREATED);
                chargeReFundManage.setApplyName(config.getApplyName());
                chargeReFundManage.setApplyUserNo(config.getApplyUserNo());
            }else{
                chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_SUCCESS);

                //退款成功修改状态
                orderInterim.setOrderStatus(ChargeOrderStatusEnum.ORDER_CLOSE);
                orderInterim.setOptStatus(ChargeOrderStatusEnum.ORDER_REFUND);
                orderInterim.setModifyTime(TimeUtil.timestamp());
                jdbcSession.updateById(orderInterim);

                /** 编号，模块，功能，账单状态，状态，说明，操作人 */
                commonService.insetLogger(orderInterim.getInterimOrderNo(),
                        ChargeLogEnum.LOG_CHARGE_ORDER_INT.getDesc(),
                        "退款操作",
                        ChargeOrderStatusEnum.ORDER_REFUND.getDesc(),
                        ChargeOrderStatusEnum.ORDER_CLOSE.getDesc(), "退款成功！", chargeReFundManage.getCreateName());

                //修改账单状态
                ChargeBillInterim billInterim = jdbcSession.findOne(ChargeBillInterim.class)
                        .eq("interimBillNo",orderInterim.getInterimBillNo()).exe();

                billInterim.setBillStatus(ChargeBillStatusEnum.BILL_PAID_CLOSE);
                billInterim.setChargeStatus(ChargeBillStatusEnum.BILL_REFUND);
                billInterim.setModifyTime(TimeUtil.timestamp());
                billInterim.setUpdateName(chargeReFundManage.getCreateName());
                jdbcSession.updateById(billInterim);

                /** 编号，模块，功能，账单状态，状态，说明，操作人 */
                commonService.insetLogger(billInterim.getInterimBillNo(),
                        ChargeLogEnum.LOG_CHARGE_BILL_INT.getDesc(),
                        "退款操作",
                        ChargeBillStatusEnum.BILL_PAID_CLOSE.getDesc(),
                        ChargeBillStatusEnum.BILL_REFUND.getDesc(), "退款成功！", chargeReFundManage.getCreateName());
            }
            chargeReFundManage.setRefundType("取消订单");
            chargeReFundManage.setRefundMethod(config.getRefundMethod());
            chargeReFundManage.setUserNO(orderInterim.getUserNo());
            chargeReFundManage.setUserName(orderInterim.getChargeName());
            chargeReFundManage.setRefundAmount(orderInterim.getOrderAmount());
            chargeReFundManage.setOrderAmount(orderInterim.getOrderAmount());
            chargeReFundManage.setRefundMethod("1");
            chargeReFundManage.setCommunityNo(orderInterim.getCommunityNo());
            jdbcSession.insert(chargeReFundManage);
        }else{
            logger.error("临时退款订单：{}，请先设置退款信息！",chargeReFundManage.getOrderNo());
            return Result.error(1231,"请先设置退款信息！");
        }

        // 调用第三方接口退款
        if(chargeReFundManage.getApplyStatus().equals(ChargeStatusEnum.CS_SUCCESS)) {

            return thirdCall(chargeReFundManage);
        }

        return Result.success();
    }

    /**
     * 常规入口
     * @param chargeReFundManage
     * @return
     */
    private Object routineAmount(ChargeReFundManage chargeReFundManage) throws Exception {

        //请求订单
        ChargeOrderManage orderManage = jdbcSession.findOne(ChargeOrderManage.class)
                .eq("orderNo",chargeReFundManage.getOrderNo()).exe();

        //1、查詢是否有配置数据
        ChargeRefundConfig config= jdbcSession.findOne(ChargeRefundConfig.class)
                .eq("deleted", false)
                .eq("communityNo",orderManage.getCommunityNo())
                .eq("status",true).exe();

        if(null != config ){
            //需要审核
            if(config.getApproveMethod().getId().equals(EnableStateEnum.UNUSED.getId())){
                chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_UN_TREATED);
                chargeReFundManage.setApplyName(config.getApplyName());
                chargeReFundManage.setApplyUserNo(config.getApplyUserNo());
            }else{
                chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_SUCCESS);

                //退款成功修改状态
                orderManage.setOrderStatus(ChargeOrderStatusEnum.ORDER_CLOSE);
                orderManage.setOptStatus(ChargeOrderStatusEnum.ORDER_REFUND);
                orderManage.setModifyTime(TimeUtil.timestamp());
                jdbcSession.updateById(orderManage);

                /** 编号，模块，功能，账单状态，状态，说明，操作人 */
                commonService.insetLogger(orderManage.getOrderNo(),
                        ChargeLogEnum.LOG_CHARGE_ORDER_COM.getDesc(),
                        "退款操作",
                        ChargeOrderStatusEnum.ORDER_CLOSE.getDesc(),
                        ChargeOrderStatusEnum.ORDER_REFUND.getDesc(), "退款成功！", orderManage.getUpdateName());

                //修改子账单的状态
                List<ChargeOrderItem> orderItemList = jdbcSession.findArray(ChargeOrderItem.class)
                        .eq("orderNo",chargeReFundManage.getOrderNo())
                        .exe();
                List<String> itemBillNoList = new ArrayList<>();
                for (int i = 0; i < orderItemList.size(); i++) {
                    ChargeOrderItem orderItem = orderItemList.get(i);
                    orderItem.setOrderStatus(ChargeOrderStatusEnum.ORDER_CLOSE);
                    jdbcSession.updateById(orderItem);
                    itemBillNoList.add(orderItem.getItemBillNo());
                }

                //修改账单状态
                updateStatus(orderManage.getHouseBillNo(),chargeReFundManage.getCreateName(),itemBillNoList);
            }
            chargeReFundManage.setHouseNo(orderManage.getHouseNo());
            chargeReFundManage.setOrderYearMonth(orderManage.getOrderYearMonth());
            chargeReFundManage.setRefundType("取消订单");
            chargeReFundManage.setRefundMethod(config.getRefundMethod());
            chargeReFundManage.setHouseBillNo(orderManage.getHouseBillNo());
            chargeReFundManage.setCommunityNo(orderManage.getCommunityNo());
            chargeReFundManage.setUserNO(orderManage.getUserNo());
            chargeReFundManage.setUserName(orderManage.getChargeName());
            chargeReFundManage.setOrderAmount(orderManage.getOrderAmount());
            chargeReFundManage.setRefundAmount(orderManage.getOrderAmount());
            jdbcSession.insert(chargeReFundManage);
        }else{
            logger.error("小区：{},常规退款订单：{}，请先设置退款信息！",orderManage.getCommunityName(),chargeReFundManage.getOrderNo());
            return Result.error(1231,"请先设置退款信息！");
        }

        // 调用第三方接口退款
        if(chargeReFundManage.getApplyStatus().equals(ChargeStatusEnum.CS_SUCCESS)) {

            return thirdCall(chargeReFundManage);
        }

        return Result.success();
    }

    /**
     * 调用第三方
     * @param chargeReFundManage
     * @return
     * @throws Exception
     */
    private Object thirdCall(ChargeReFundManage chargeReFundManage) throws Exception {

        ChargePayManage payManage = jdbcSession.findOne(ChargePayManage.class)
                .eq("status",ChargeOrderStatusEnum.ORDER_PAY_SUCCESS.getId())
                .eq("orderNo",chargeReFundManage.getOrderNo()).exe();

        if(null == payManage){
            logger.error("orderNo:{},没有找到第三方订单！",chargeReFundManage.getOrderNo());
            return Result.error(123,"{},没有找到第三方订单！",chargeReFundManage.getOrderNo());
        }

        JSONObject data = commonClient.reFundObj(payManage.getOrderNoThird(),chargeReFundManage.getRemark());

        if (Objects.nonEmpty(data)) {
            logger.info("退款请求回调参数！参数：{}", data);
            /**
             * OrderRefundResDto{thirdOrderId='210829202119476100', vendorTradeNo='50300909292021082911974419969', success=true,
             * firstSuccess=true, refundDate=Sun Aug 29 20:38:42 CST 2021, description='null'}
             * 退款请求回调参数！参数：
             * {"firstSuccess":true,"refundDate":"2021-08-29 20:52:11","success":true,"thirdOrderId":"210829205055597101",
             * "vendorTradeNo":"50300909452021082911975111372"}
             */

            boolean status = data.getBoolean("success");
            boolean firstSuccess = data.getBoolean("firstSuccess");
            String refundDate = data.getString("refundDate");
            String thirdOrderId = data.getString("thirdOrderId");
            String vendorTradeNo = data.getString("vendorTradeNo");

            if (status) {
                chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_SUCCESS);
            } else {
                chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_FALL);
            }

            //chargeReFundManage.setThirdReason();
            chargeReFundManage.setThirdStatus(status);
            chargeReFundManage.setThirdTime(refundDate);
            chargeReFundManage.setRefundMethod("1");
            chargeReFundManage.setThirdOderNo(thirdOrderId);

            return Result.success(jdbcSession.updateById(chargeReFundManage));
        }

        return Result.error(123,"{},没有更新到数据！",chargeReFundManage.getOrderNo());
    }

    @Override
    public Object update(ChargeReFundManage chargeReFundManage) throws Exception {

        /**
         * 退款审核接口
         */
        if(ChargeStatusEnum.CS_SUCCESS.equals(chargeReFundManage.getApplyStatus())){

            // 调用第三方接口退款
            //chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_SUCCESS);
            if(chargeReFundManage.getApplyStatus().equals(ChargeStatusEnum.CS_SUCCESS)) {
                thirdCall(chargeReFundManage);
            }

            if(CommonEnum.COM_PAY_ROUTINE.getId().equals(chargeReFundManage.getOrderOrigin())) { //常规
                //请求订单
                ChargeOrderManage orderManage = jdbcSession.findOne(ChargeOrderManage.class)
                        .eq("orderNo", chargeReFundManage.getOrderNo()).exe();
                //退款成功修改状态
                orderManage.setOrderStatus(ChargeOrderStatusEnum.ORDER_CLOSE);
                orderManage.setOptStatus(ChargeOrderStatusEnum.ORDER_REFUND);
                orderManage.setModifyTime(TimeUtil.timestamp());
                jdbcSession.updateById(orderManage);

                /** 编号，模块，功能，账单状态，状态，说明，操作人 */
                commonService.insetLogger(orderManage.getOrderNo(),
                        ChargeLogEnum.LOG_CHARGE_ORDER_COM.getDesc(),
                        "退款操作",
                        ChargeOrderStatusEnum.ORDER_CLOSE.getDesc(),
                        ChargeOrderStatusEnum.ORDER_REFUND.getDesc(), "退款成功！", orderManage.getUpdateName());


                //修改子账单的状态
                List<ChargeOrderItem> orderItemList = jdbcSession.findArray(ChargeOrderItem.class)
                        .eq("orderNo",chargeReFundManage.getOrderNo()).exe();
                List<String> itemBillNoList = new ArrayList<>();
                for (int i = 0; i < orderItemList.size(); i++) {
                    ChargeOrderItem orderItem = orderItemList.get(i);
                    orderItem.setOrderStatus(ChargeOrderStatusEnum.ORDER_REFUND);
                    jdbcSession.updateById(orderItem);
                    itemBillNoList.add(orderItem.getItemBillNo());
                }

                //修改账单状态
                updateStatus(orderManage.getHouseBillNo(),chargeReFundManage.getUpdateName(),itemBillNoList);

                return Result.success(jdbcSession.updateById(chargeReFundManage));

            }else if (CommonEnum.COM_PAY_INTERIM.getId().equals(chargeReFundManage.getOrderOrigin())){// 临时
                //请求订单
                ChargeOrderInterim orderInterim = jdbcSession.findOne(ChargeOrderInterim.class)
                        .eq("interimOrderNo",chargeReFundManage.getOrderNo()).exe();
                //退款成功修改状态
                orderInterim.setOrderStatus(ChargeOrderStatusEnum.ORDER_CLOSE);
                orderInterim.setOptStatus(ChargeOrderStatusEnum.ORDER_REFUND);
                orderInterim.setModifyTime(TimeUtil.timestamp());
                jdbcSession.updateById(orderInterim);

                /** 编号，模块，功能，账单状态，状态，说明，操作人 */
                commonService.insetLogger(orderInterim.getInterimOrderNo(),
                        ChargeLogEnum.LOG_CHARGE_ORDER_INT.getDesc(),
                        "退款操作",
                        ChargeOrderStatusEnum.ORDER_REFUND.getDesc(),
                        ChargeOrderStatusEnum.ORDER_CLOSE.getDesc(), "退款成功！", chargeReFundManage.getUpdateName());

                //修改账单状态
                ChargeBillInterim billInterim = jdbcSession.findOne(ChargeBillInterim.class)
                        .eq("interimBillNo",orderInterim.getInterimBillNo()).exe();

                billInterim.setBillStatus(ChargeBillStatusEnum.BILL_PAID_CLOSE);
                billInterim.setChargeStatus(ChargeBillStatusEnum.BILL_REFUND);
                billInterim.setModifyTime(TimeUtil.timestamp());
                billInterim.setUpdateName(chargeReFundManage.getUpdateName());
                jdbcSession.updateById(billInterim);

                /** 编号，模块，功能，账单状态，状态，说明，操作人 */
                commonService.insetLogger(billInterim.getInterimBillNo(),
                        ChargeLogEnum.LOG_CHARGE_BILL_INT.getDesc(),
                        "退款操作",
                        ChargeBillStatusEnum.BILL_PAID_CLOSE.getDesc(),
                        ChargeBillStatusEnum.BILL_REFUND.getDesc(), "退款成功！", chargeReFundManage.getUpdateName());
            }else{
                return Result.error(1231,"不支持的订单！");
            }

        }else if (ChargeStatusEnum.CS_REFUSE.equals(chargeReFundManage.getApplyStatus())){
            chargeReFundManage.setApplyStatus(ChargeStatusEnum.CS_REFUSE);
        }

        chargeReFundManage.setApplyTime(TimeUtil.timestamp());
        return jdbcSession.updateById(chargeReFundManage);
    }


    /**
     * 修改账单状态
     * @param houseBillNo
     * @param optName
     * @return
     */
    private void updateStatus(String houseBillNo,String optName,List<String> itemBillNoList){
        //2、修改账单状态
        List<ChargeBillItems> itemsList = jdbcSession.findArray(ChargeBillItems.class)
                .in("itemBillNo",itemBillNoList).exe();

        BigDecimal payAmount = BigDecimal.ZERO;
        for (int i = 0; i < itemsList.size(); i++) {
            ChargeBillItems items = itemsList.get(i);
            items.setBillStatus(ChargeBillStatusEnum.BILL_PAID_CLOSE);
            items.setChargeStatus(ChargeBillStatusEnum.BILL_REFUND);
            items.setModifyTime(TimeUtil.timestamp());
            items.setUpdateName(optName);

            payAmount = BigDecimalUtils.add(payAmount, items.getPaymentAmount(), 2);
            jdbcSession.updateById(items);

            /** 编号，模块，功能，账单状态，状态，说明，操作人 */
            commonService.insetLogger(items.getItemBillNo(),
                    ChargeLogEnum.LOG_CHARGE_BILL_COM.getDesc(),
                    "退款操作",
                    ChargeBillStatusEnum.BILL_PAID_CLOSE.getDesc(),
                    ChargeBillStatusEnum.BILL_REFUND.getDesc(), "退款成功！", optName);
        }

        //1、房屋状态修改
        ChargeBillHouse billHouse = jdbcSession.findOne(ChargeBillHouse.class)
                .eq("houseBillNo",houseBillNo).exe();
        billHouse.setModifyTime(TimeUtil.timestamp());
        billHouse.setUpdateName(optName);

        // 查询是否有待缴费的
        List<ChargeBillItems> paidItemsList = new ArrayList<>();
        List<ChargeBillItems> allItemsList = jdbcSession.findArray(ChargeBillItems.class)
                .eq("houseBillNo",houseBillNo)
                .exe();
        for (ChargeBillItems each : allItemsList) {
            if (each.getBillStatus() == ChargeBillStatusEnum.BILL_WAIT_PAID) {
                paidItemsList.add(each);
            }
        }
        if (Objects.nonEmpty(paidItemsList)) {
            billHouse.setBillStatus(ChargeBillStatusEnum.BILL_WAIT_PAID);
            billHouse.setChargeStatus(ChargeBillStatusEnum.BILL_PAID_PART);
            billHouse.setBillAmountPaid(BigDecimalUtils.sub(billHouse.getBillAmountPaid(), payAmount, 2));
        } else {
            billHouse.setBillStatus(ChargeBillStatusEnum.BILL_PAID_CLOSE);
            billHouse.setChargeStatus(ChargeBillStatusEnum.BILL_REFUND);

            BigDecimal amount = BigDecimal.ZERO;
            for (ChargeBillItems each : allItemsList) {
                amount = BigDecimalUtils.add(amount, each.getBillAmount(), 2);
            }
            billHouse.setBillAmount(amount);
            billHouse.setBillAmountUnPaid(amount);
            billHouse.setBillAmountPaid(BigDecimal.ZERO);
        }
        jdbcSession.updateById(billHouse);

        /** 编号，模块，功能，账单状态，状态，说明，操作人 */
        commonService.insetLogger(houseBillNo,
                ChargeLogEnum.LOG_CHARGE_BILL_COM.getDesc(),
                "退款操作",
                ChargeBillStatusEnum.BILL_PAID_CLOSE.getDesc(),
                ChargeBillStatusEnum.BILL_REFUND.getDesc(), "退款成功！", optName);
    }

    @Override
    public Object deleteById(String id) {
        ChargeReFundManage result = Pool.get(ChargeReFundManage.class, id);
        if (result != null) {
            result.setDeleted(true);
            jdbcSession.updateById(result);
        }
        return 1;
    }
}
